﻿<!DOCTYPE html>
<html>
<head>
    <title>收款卡管理</title>
    <script src="/js/header.js"></script>
    <link href="/lib/jquery/jquery-ui.min.css" rel="stylesheet" />
    <script src="/lib/jquery/jquery-ui.min.js"></script>
</head>
<body>
    <div class="data-wrap case" id="container">
        <div class="data-tool clearfix">
            <div class="pull-left form-inline ">
            </div>
            <div class="pull-right">
                <form class="form-inline" id="formSearch">
                    <div class="input-group input-group-sm">
                        <div class="input-sm"><input name="autoRefresh" type="checkbox" title="10秒自动刷新" /><label id="time" class="wd100">10秒自动刷新</label></div>
                    </div>
                    <div class="input-group input-group-sm">
                        <label class="input-group-addon m5_l">公司名称：</label>
                        <input class="form-control" name="CompanyName" type="text" />
                    </div>

                    <div class="input-group input-group-sm">
                        <label class="input-group-addon m5_l">银行名称：</label>
                        <input class="form-control" name="BankName" type="text" />
                    </div>

                    <div class="input-group input-group-sm">
                        <label class="input-group-addon m5_l">银行卡号：</label>
                        <input class="form-control" name="CardNumber" type="text" />
                    </div>

                    <div class="input-group input-group-sm">
                        <label class="input-group-addon m5_l">用戶名：</label>
                        <input class="form-control" name="CardName" type="text" />
                    </div>

                    <div class="input-group input-group-sm">
                        <label class="input-group-addon m5_l">启用状态：</label>
                        <select class="form-control" name="EnableStatus">
                            <option value="">请选择</option>
                            <option value="1">启用</option>
                            <option value="2">禁用</option>
                        </select>
                    </div>
                    <div class="input-group input-group-sm">
                        <label class="input-group-addon m5_l">更新时间：</label>
                        <select class="form-control" name="lastUpdateDateSortType">
                            <option value="">请选择</option>
                            <option value="2" selected>不正常</option>
                            <option value="1">正常</option>
                        </select>
                    </div>
                    <button type="button" class="btn btn-default btn-sm active" id="btnSearch"><span class="glyphicon glyphicon-search"></span> 搜索</button>
                </form>
            </div>
        </div>
        <div class="paging">
        </div>

    </div>
    <script type="text/x-dot-template" id="templatePager">
        <div class="data-body data-scroll">
            <div class="data-view">
                <div class="data-div-view table-responsive">
                    <table class="table table-hover table-striped table-bordered">
                        <thead>
                            <tr>
                                <th class="t_l wd150">公司名称</th>
                                <th class="t_l wd100">银行名称</th>
                                <th class="t_l wd125">银行卡号</th>
                                <th class="t_l wd100">用户名</th>
                                <th class="t_c wd75">使用状态</th>
                                <th class="t_c wd75">启用状态</th>
                                <th class="t_r bold wd75">参考余额</th>
                                <th class="t_r wd100">收款费率(%)</th>
                                <th class="wd130 wd100">更新时间</th>
                                <th class="t_l wd150">虚拟机编码</th>
                                <th class="t_l">备注</th>
                                <th class="wd125">操作</th>
                            </tr>
                        </thead>
                        <tbody>
                            {{? it.tData && it.tData.length>0}}
                            {{~it.tData :item:index}}
                            <tr>
                                <td class="t_l wd150" title="{{= item.companyNameEn }}">{{= item.companyName }}</td>
                                <td class="t_l wd100">{{= item.bankName }}</td>
                                <td class="t_l wd125">{{= item.cardNumber }}</td>
                                <td class="t_l wd100">{{= item.cardName }}</td>
                                <td class="t_c wd75">
                                    {{? item.usingStatus==1 }}
                                    <span class="green bold">有效</span>
                                    {{?? }}
                                    <span class="red bold">冻结</span>
                                    {{? }}
                                </td>
                                <td class="t_c wd75">{{= FlashPay.Util.GetCardEnableStatusValue(item.enableStatus) }}</td>
                                <td class="t_r bold wd75">{{= FlashPay.Util.FormatNumber(item.balance,2)}}</td>
                                <td class="t_r wd100">{{= FlashPay.Util.FormatNumber(item.depositFeeRatio*100,2) }} (%)</td>
                                <td class="wd130" {{=(item.timeDifference>5 && item.enableStatus==1)?"style=\"background-color:red;color:white\"":"" }}>
                                    {{=item.balanceLastUpdate==null?"":item.balanceLastUpdate}}
                                </td>
                                <td class="t_l wd150" title="{{= item.vmClientId==null?"":item.vmClientId }}">
                                    {{?  item.vmClientId}}{{= item.vmClientId }}{{??}}{{?}}
                                </td>
                                {{? it.statusCode=="100" }}
                                <td class="t_l wd100" title="{{= item.remark==null?"":item.remark }}">{{=item.remark==null?"":item.remark}}</td>
                                {{??}}
                                <td class="t_l wd100">*.*.*.*</td>
                                {{?}}
                                <td class="wd125">
                                    {{? item.enableStatus==1 }}
                                    <a class="btn btn-warning btn-xs" data-confirm=' "{{= item.cardName }}" <br>确定要<span class="orange">禁用</span>该银行卡？' data-href="/Payment/PaymentCardUpdateStatus?id={{= item.bcid}}&status=2">禁用</a>
                                    {{?? }}
                                    <a class="btn btn-success btn-xs" data-confirm=' "{{= item.cardName }}" <br>确定要<span class="orange">启用</span>该银行卡？' data-href="/Payment/PaymentCardUpdateStatus?id={{= item.bcid}}&status=1">启用</a>
                                    <button type="button" class="btn btn-default btn-xs" data-modal="/view/receipt/receiptcardEdit.html?id={{= item.bcid}}" data-title="编辑 - {{= item.bankName }}-{{= item.cardName }}-{{= FlashPay.Util.SubCardNumber(item.cardNumber) }}" data-width="452" data-height="120">
                                        <span class="glyphicon glyphicon-edit"></span> 编辑
                                    </button>
                                    {{? }}
                                </td>
                            </tr>
                            {{~}}
                            {{??}}
                            <tr class="noRecord">
                                <td colspan="12">暂无记录！</td>
                            </tr>
                            {{?}}
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
        <!-- 必要的分页参数设置 -->
        <input type="hidden" id="TotalCount" value="{{=it.totalCount}}" />
    </script>
    <script type="text/javascript">
        var wait = 10;
        var autoRefresh = $("input[name='autoRefresh']");

        $(function () {
            FlashPay.UI.DataAutoHeight();
            doSearch();
            $("body").keydown(function (event) {
                if (event.keyCode == "13") {
                    doSearch();
                }
            });
            $("#btnSearch").click(function () {
                FlashPay.UI.DoSearch();
            });

            //setTimeout(doSearch, 1000 * 60 * 10);
            $(autoRefresh).change(function () {
                time();
            });
        });

        //倒时计
        function time() {
            var obj = document.getElementById("time");

            var isauto = $(autoRefresh).is(':checked');
            if (!isauto) {
                obj.innerText = "10秒自动刷新";
                return false;
            }

            if (wait == 0) {
                obj.innerText = "10秒自动刷新";
                wait = 10;

                if (isauto) {
                    setTimeout(function () { time(); }, 1000);
                }

                FlashPay.UI.DoSearch();
            } else {
                obj.innerText = wait + "秒自动刷新";
                wait--;
                setTimeout(function () { time(); }, 1000);
            }
        }

        function doSearch() {
            FlashPay.UI.Pager(".paging", { templateId: "templatePager", pageSize: 15, ajax: { url: '/Receipt/GetReceiptCardList?cardType=1&adjustStatus=1' } });
        }

        //公司名称搜索
        $("input[name='CompanyName']").autocomplete({
            minLength: 1,
            source: function (request, response) {
                FlashPay.Util.Ajax({
                    url: '/Role/CompanySearch',
                    type: 'POST',
                    data: { companyName: $("input[name='CompanyName']").val() },
                    success: function (res) {
                        if (res.success) {
                            if (res.data != null && res.data.length > 0) {
                                response($.map(res.data, function (item) {
                                    return {
                                        label: item.companyName,
                                        value: item.companyName,
                                        id: item.companyID
                                    }
                                }))
                            }
                        } 
                    }
                });
            }
        });
    </script>
</body>
</html>